import { formatTime, formatSeconds } from '@/utils'
import i18n from '@/locales/index' 
const { t } = i18n.global
export const processFormRule = {
  effectiveDate: [{ required: true, message: t('other.pleaseInputEffectiveDate') }]
}
export const processRule = {
  section: [{ required: true, message: t('basicData.pleaseSelectSection') }],
  sortField: [{ required: true, message: t('basicData.pleaseInputSortNo') }, { pattern: /(^[0-9]([0-9]+)?$)/, message: t('other.intOnly')}],
  processNo: [{ required: true, message: t('basicData.pleaseInputProcessNo') }, { pattern: /(^[0-9]([0-9]+)?$)/, message: t('other.intOnly')}],
  name: [{ required: true, message: t('basicData.pleaseInputProcessName') }], 
  processCode: [{ required: true, message: t('basicData.pleaseInputProcessCodes') }],
  standardSeconds: [{ required: true, message: t('other.pleaseInputStandardWorkTime') },{ pattern: /^\d{1,5}(\.\d{1,8})?$/, message: t('components.ruleFiveEightNumber') }],
  labourCost: [{ required: true, message: t('other.pleaseInputWages') },{ pattern: /^\d{1,5}(\.\d{1,8})?$/, message: t('components.ruleFiveEightNumber') }]
}
// export const listHeaders =  [ '工段', '排序号', '工序号', '工序名称', '工序代码', '标准工时(秒)', '工价(元)', '工艺指导说明', '图片/视频']
export const listHeaders =  [ t('basicData.section'), t('basicData.processNo'),  t('basicData.processNames'), t('basicData.processCodes'), t('common.state'), t('basicData.standardTimeSec'),  t('basicData.priceYuan'),t('hangManage.artGuideIns'),t('hangManage.imgVideo') ]

export const addList = [
{
  sortField: 1,
  section: t('components.dg'),
  processNo: 1,
  name: t('hangManage.hang'),
  processCode: 1,
  standardSeconds: 0,
  labourCost: 0
}]
export const queryStatusOptions = [
  { value: 0, key: t('other.unProduction') },
  { value: 1, key: t('other.inProduct') },
  { value: 2, key: t('sysManage.completed')},
]
export const modalColumns =  [
  {
    title: t('common.sequenceNo'), dataIndex: 'index', key: 'index', align: 'center', width: 60,
    customRender: ({ index }) => {
      return index + 1
    }
  },
  { title: t('basicData.section'), dataIndex: 'section', key: 'section', align: 'center', width: 90 },
  { title: t('basicData.sortNo'), dataIndex: 'sortField', key: 'sortField', align: 'center', width: 90 },
  { title: t('basicData.processNo'), dataIndex: 'processNo', key: 'processNo', align: 'center', width: 90 },
  { title: t('basicData.processCodes'), dataIndex: 'processCode', key: 'processCode', align: 'center', width: 100 },
  { title: t('basicData.processNames'), dataIndex: 'name', key: 'name', align: 'center', width: 100 },
  {
    title: t('basicData.standardTimeSec'), dataIndex: 'standardSeconds', key: 'standardSeconds', align: 'center', width: 120,
    customRender: ({ record }) => {
      return record.standardSeconds
    }
  },
  { title: t('basicData.priceYuan'), dataIndex: 'labourCost', key: 'labourCost', align: 'center', width: 100 }
]

export const normalColumns =  [
  {
    title: t('common.sequenceNo'), dataIndex: 'index', key: 'index', align: 'center', width: 80,
    customRender: ({ index }) => {
      return index + 1
    }
  },
  { title: t('basicData.processVerName'), dataIndex: 'name', key: 'name', align: 'center', width: 180 },
  { title: t('basicData.totalTimeSec'), dataIndex: 'standardTotalMinute', key: 'standardTotalMinute', align: 'center', width: 130,
  customRender: ({ record }) => {
    return record.standardTotalMinute && formatSeconds(record.standardTotalMinute)
  } 
},
  { title: t('basicData.totalPriceYuan'), dataIndex: 'totalLabourCost', key: 'totalLabourCost', align: 'center', width: 130,
    customRender: ({ text }) => {
      return text 
    } 
  },
  { title: t('common.effectDate'), dataIndex: 'effectiveDate', key: 'effectiveDate', align: 'center', width: 130, 
    customRender: ({ text }) => {
      return formatTime(text, 'YYYY-MM-DD')
    } 
  },
  {
    title: t('common.createTime'), dataIndex: 'createTime', key: 'createTime', align: 'center', width: 170,
    customRender: ({ text }) => {
      return formatTime(text, 'YYYY-MM-DD HH:mm:ss')
    }
  },
  {
    title: t('common.lastEditTime'), dataIndex: 'updateTime', key: 'updateTime', align: 'center', width: 170,
    customRender: ({ text }) => {
      return formatTime(text, 'YYYY-MM-DD HH:mm:ss')
    }
  },
  { title:  t('common.state'), dataIndex: 'status', key: 'status', align: 'center', width: 100 },
  { title:  t('common.founder'), dataIndex: 'createBy', key: 'createBy', align: 'center', width: 100 },
  { title:  t('common.operate'), dataIndex: 'operate', key: 'operate', align: 'center', width: 200, fixed: 'right' }
]
export const localColumns =  [
  {
    title: t('common.sequenceNo'), dataIndex: 'index', key: 'index', align: 'center', width: 80,
    customRender: ({ index }) => {
      return index + 1
    }
  },
  { title: t('basicData.processVerName'), dataIndex: 'name', key: 'name', align: 'center', width: 180 },
  { title: t('basicData.totalTimeSec'), dataIndex: 'standardTotalMinute', key: 'standardTotalMinute', align: 'center', width: 130,
  customRender: ({ record }) => {
    return record.standardTotalMinute && formatSeconds(record.standardTotalMinute)
  } 
},
  { title: t('basicData.totalPriceYuan'), dataIndex: 'totalLabourCost', key: 'totalLabourCost', align: 'center', width: 130,
    customRender: ({ text }) => {
      return text 
    } 
  },
  { title: t('common.effectDate'), dataIndex: 'effectiveDate', key: 'effectiveDate', align: 'center', width: 130, 
    customRender: ({ text }) => {
      return formatTime(text, 'YYYY-MM-DD')
    } 
  },
  {
    title: t('common.createTime'), dataIndex: 'createTime', key: 'createTime', align: 'center', width: 170,
    customRender: ({ text }) => {
      return formatTime(text, 'YYYY-MM-DD HH:mm:ss')
    }
  },
  {
    title: t('common.lastEditTime'), dataIndex: 'updateTime', key: 'updateTime', align: 'center', width: 170,
    customRender: ({ text }) => {
      return formatTime(text, 'YYYY-MM-DD HH:mm:ss')
    }
  },
  { title: '状态', dataIndex: 'status', key: 'status', align: 'center', width: 100 },
  { title: '创建人', dataIndex: 'createBy', key: 'createBy', align: 'center', width: 100 }
]